package com.boruishangge.aplus_app.activity

import android.Manifest
import android.annotation.TargetApi
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.view.View
import android.view.Window
import android.view.WindowInsets
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import com.alibaba.android.arouter.launcher.ARouter
import com.boruishangge.common.APlusARoute
import com.boruishangge.common.entiy.Loginbean
import com.boruishangge.aplus_app.R
import com.boruishangge.persagysdk.base.BaseActivity


class SplashActivity :BaseActivity() {
    val PERMISSION_TAKE_PICTURE = arrayOf<String>(
        Manifest.permission.READ_PHONE_STATE,
        Manifest.permission.READ_EXTERNAL_STORAGE,
        Manifest.permission.WRITE_EXTERNAL_STORAGE
    )


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_splash_view)
        whiteStatusBar()
        if (!isTaskRoot()) {
            finish()
            return
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            val window: Window = window
            val decorView: View = window.getDecorView()
            decorView.setOnApplyWindowInsetsListener(object : View.OnApplyWindowInsetsListener {
                @TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
                override fun onApplyWindowInsets(v: View, insets: WindowInsets?): WindowInsets? {
                    val defaultInsets: WindowInsets = v.onApplyWindowInsets(insets)
                    return defaultInsets.replaceSystemWindowInsets(
                        defaultInsets.systemWindowInsetLeft,
                        0,
                        defaultInsets.systemWindowInsetRight,
                        defaultInsets.systemWindowInsetBottom
                    )
                }
            })
            ViewCompat.requestApplyInsets(decorView)
            //将状态栏设成透明，如不想透明可设置其他颜色
            window.setStatusBarColor(ContextCompat.getColor(this, android.R.color.transparent))
        }
    }


    override fun onResume() {
        super.onResume()
        loginSuccess()
        Handler().postDelayed({jumActivity()}, 1500)
    }
   fun jumActivity(){
     startActivity(Intent(this, IndexActivity::class.java))

//       ARouter.getInstance().build(APlusARoute.index_activity_Router).navigation()
       finish()
    }
    fun  loginSuccess(){

    }

    fun setUserInfo(it:Loginbean ){

    }


}